#!/usr/bin/env node

//把二进制的图片文件转化成base64编码字符串

const fs = require('fs'),
    http = require('http');

const file_name = process.argv[2];
const buf = fs.readFileSync(file_name);
const img_base64 = buf.toString('base64');

const html = `<!doctype html><html><body><img src="data:image/jpg;base64,${img_base64}"></body></html>`;

http.createServer((req,res)=>{
    res.end(html);
}).listen(8080);
